//获取微信授权 用户信息
function loginObtain() {
	let login_key = uni.getStorageSync('loginInfo_key')
	if (!login_key || login_key == '' || login_key == null || login_key == undefined) {
		uni.getUserProfile({
			desc: '用于完善会员资料',
			success: (info) => { //这里请求接口
				uni.setStorageSync('loginInfo_key', info)
				uni.navigateBack({
					delta: 1,
					success: function() {
						let page = getCurrentPages().pop(); //跳转页面成功之后
						if (!page) return;
						page.onLoad(); //如果页面存在，则重新刷新页面
					}
				});
			},
			fail: (res) => {
				console.log(res)
			}
		})
	} else {}
}

//获取用户地址坐标
function addressObtain() {
	let address_key = uni.getStorageSync('address_key')
	if (!address_key || address_key == '' || address_key == null || address_key == undefined || address_key ==
		'undefined') {
		uni.authorize({
			scope: 'scope.userLocation',
			success() {
				uni.getLocation({
					type: 'wgs84',
					success: function(res) {
						uni.setStorageSync('address_key', res)
					}
				})
			}
		})
	}

}

function appTest(){
	console.log(11111111)
}

export default {
	loginObtain,
	addressObtain,
	appTest
}
